<template>
  <div
    title="预览"
    width="500px"
    destroy-on-close
    :before-close="() => $emit('update:showExpressSheet', false)"
    :modal="true"
    :close-on-click-modal="false">
    <div class="pritcontent">
      <div id="printTests" ref="printTests">
        <div class="contaner" v-for="(item, index) in skuDistributorData" :key="index + 'skuB'">
          <div class="expressSheet">
            <div class="header">
              <div class="expressSheet-title-left">
                <div class="line"></div>
                <div>料金別納</div>
                <div>郵 便</div>
              </div>

              <div class="expressSheet-title-right">
                <div class="top">取扱注意</div>
                <div class="center">割れ物注意</div>
                <div class="bottom">{{ item.acknowledgment }}</div>
              </div>
            </div>
            <div class="expressSheet-content">
              <div class="expressSheet-content-all">
                <div class="localhost" data-th-text="${print.receivePostcode}">
                  {{ item.receivePostcode }}
                </div>
                <div class="localhost" data-th-text="${print.address1}">{{ item.address1 }}</div>
                <div class="localhost" data-th-text="${print.address2}">{{ item.address2 }}</div>
                <div
                  class="localhosts"
                  data-th-text="${print.address3}"
                  style="font-size: 16px; margin-bottom: 2px; color: black; max-height: 40px">
                  {{ item.address3 }}
                </div>
                <div class="userName" data-th-text="${print.receiveName}">{{ item.receiveName }}</div>
              </div>
              <div class="packageInfor">
                <div class="packageInforList">
                  <div>Standard</div>
                  <div data-th-text="${print.standard}">{{ item.Standard }}</div>
                </div>
                <div class="packageInforList">
                  <div>{{ item.packageNo }}</div>
                  <div>{{ item.packageNum }}</div>
                </div>
              </div>
            </div>
            <div class="footer">
              <div class="footer-left">
                <div class="footer-left-list" data-th-text="${print.shopName}" style="margin: 0 0 4px 0">
                  発送元:
                </div>
                <div class="footer-left-list" data-th-text="${print.postcode}">
                  {{ item.postcode }}
                </div>
                <div class="footer-left-list" data-th-text="${print.shopName}" style="white-space: wrap;height: 26px;">{{ item.address }}</div>
                <div class="footer-left-list" data-th-text="${print.address}">{{ item.shopName }}</div>
              </div>
              <div class="expressSheet-footer-right codeItem" :id="`print${index}`" ref="codeItem"></div>
            </div>
          </div>
        </div>
      </div>
    </div>
    <!-- <span slot="footer" class="dialog-footer">
      <el-button @click="$emit('update:showExpressSheet', false)">取 消</el-button>
      <el-button type="primary" v-print="'#printTests'">打印</el-button>
    </span> -->
  </div>
</template>

<script>
import Print from 'vue-print-nb'
import QRCode from 'qrcodejs2'
import { skuDistributorSellerApply } from '@/api/distribution/sku/sku'
export default {
  name: 'ErpDistributionPlusWebShowExpressSheet',
  props: {
    showExpressSheet: {
      type: Boolean,
      default: false,
    },
    packageNo: {
      type: String,
      default: '',
    },
  },
  directives: {
    Print,
  },
  data() {
    return {
      skuDistributorData: [],
    }
  },

  mounted() {
    
  },

  methods: {
    getData() {
      skuDistributorSellerApply({ packageNo: Number(this.packageNo) }).then((res) => {
        this.skuDistributorData = JSON.parse(res.data).poPrint
        let self = this
        self.$nextTick(function () {
          self.skuDistributorData.map((item, index) => {
            new QRCode(`print${index}`, {
              text: item.packageNo, //页面地址 ,如果页面需要参数传递请注意哈希模式#
              width: 58, // 二维码宽度 （不支持100%）
              height: 58, // 二维码高度 （不支持100%）
            })
          })
        })
      })
    },
  },
}
</script>

<style lang="scss" scoped>
/* @media print {
  @page {
     size: landscape;
     size: portrait;
  }
} */
.pritcontent {
  color: black;
  padding: 0 100px;
  height: 546px;
  overflow-y: scroll;
}

.contaner {
  /**纸张边距微调 */
  padding: 2px 3px 1px 2px;
  page-break-after: always;
  page-break-inside: avoid;
  overflow: hidden;
}

.contaner .expressSheet {
  /* transform: rotate(-90deg); */
  /* writing-mode: horizontal-tb; */
  margin: auto;
  padding: 6px;
  width: 100%;
  height: 100%;
  border-radius: 6px;
  border: solid 2px black;
}

.contaner .expressSheet .header {
  font-size: 13px;
  display: flex;
  justify-content: space-between;
}

.contaner .expressSheet .header .expressSheet-title-left {
  overflow: hidden;
  width: 70px;
  height: 70px;
  border: solid 1px black;
  border-radius: 100%;
  font-weight: bold;
  text-align: center;
}
.contaner .expressSheet .header .expressSheet-title-center {
  width: 90px;
  height: 90px;
}

.contaner .expressSheet .header .expressSheet-title-left .line {
  height: 24px;
  border-bottom: 1px solid black;
}

.contaner .expressSheet .header .expressSheet-title-left > :nth-child(3) {
  letter-spacing: 4px;
}

.contaner .expressSheet .header .expressSheet-title-right {
  text-align: right;
  width: 174px;
  overflow: hidden;
}

.contaner .expressSheet .header .expressSheet-title-right .bottom {
  white-space: nowrap;
  text-align: right;
  width: 100%;
  font-size: 10px;
  height: 34px;
  margin-top: 20px;
}

.contaner .expressSheet .expressSheet-content {
  margin: 8px 0 12px 0;
}
.expressSheet-content-all {
  height: 144px;
}
.contaner .expressSheet .expressSheet-content .localhost {
  margin-bottom: 2px;
  height: 18px;
  font-size: 16px;
  color: black;
}

.contaner .expressSheet .expressSheet-content .userName {
  // margin: 4px 0 24px 0;
  font-weight: 500;
  font-size: 20px;
  color: black;
}

.contaner .expressSheet .expressSheet-content .packageInfor {
  font-size: 12px;
  /* width: 50%; */
  width: 100%;
}

.contaner .expressSheet .expressSheet-content .packageInfor .packageInforList {
  font-size: 13px;
  width: 100%;
  margin-bottom: 4px;
  height: 18px;
}

.contaner .expressSheet .expressSheet-content .packageInfor .packageInforList > :nth-child(1) {
  margin-left: 16px;
  float: left;
}

.contaner .expressSheet .expressSheet-content .packageInfor .packageInforList > :nth-child(2) {
  float: right;
  text-align: left;
  width: 26%;
}

.contaner .expressSheet .footer {
  position: relative;
  width: 100%;
  height: 62px;
}
.expressSheet-footer-right {
  position: absolute;
  right: 0;
  top: 0;
}
.footer-left {
  overflow: hidden;
  margin-left: -4px;
  width: 75%;
}
.footer-left-list {
  font-size: 10px;
  width: 100%;
  white-space: nowrap;
  overflow: hidden;
}
</style>
